package com.chezhujie.www.service;

import com.chezhujie.www.core.exception.ClassCheckException;
import com.chezhujie.www.core.page.Pagination;
import com.chezhujie.www.domain.Czjselectclassify;
import com.chezhujie.www.persistence.CzjselectclassifyMapper;
import com.chezhujie.www.utils.UUIDUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 首页严选商品分类
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class CzjselectclassifyService extends BaseService<Czjselectclassify>{
    @Autowired
    private CzjselectclassifyMapper czjselectclassifyMapper;

    @Autowired
    public void setBaseMapper(CzjselectclassifyMapper czjselectclassifyMapper) {
        this.baseMapper = czjselectclassifyMapper;
    }

    public List<Map<String,Object>> getListCommoditytypeId(Map<String, Object> param) {
        return czjselectclassifyMapper.listCommoditytypeId(param);
    }

    public void checkEntity(Czjselectclassify czjselectclassify) throws ClassCheckException {
        if(czjselectclassify.getSelectclassifyId()!=null&&czjselectclassify.getSelectclassifyId().length()>19){
            throw new ClassCheckException("首页严选商品分类主键不能超过19个字符");
        }
        if(czjselectclassify.getTitle()!=null&&czjselectclassify.getTitle().length()>50){
            throw new ClassCheckException("首页严选商品分类标题不能超过50个字符");
        }
        if(czjselectclassify.getCommoditytypeId()!=null&&czjselectclassify.getCommoditytypeId().length()>19){
            throw new ClassCheckException("首页严选商品分类商品分类不能超过19个字符");
        }
        if(czjselectclassify.getPicPath()!=null&&czjselectclassify.getPicPath().length()>255){
            throw new ClassCheckException("首页严选商品分类图片不能超过255个字符");
        }
        if(czjselectclassify.getPicUrl()!=null&&czjselectclassify.getPicUrl().length()>255){
            throw new ClassCheckException("首页严选商品分类图片跳转链接不能超过255个字符");
        }
    }
    public void checkListEntity(List<Czjselectclassify> listCzjselectclassify) throws ClassCheckException {

        for (Czjselectclassify czjselectclassify : listCzjselectclassify) {
            checkEntity(czjselectclassify);
        }

    }
}
